<template>
    <section class="list">
            <ul>
                <li v-for="(tagIndex, item) in tags">
                    <p @click="toggle(tagIndex)"> 
                        <Icon type="arrow-right-b"></Icon>
                        {{ item.name | tagName }} <span class="gray">{{ item.name }}</span>
                    </p>
                    <ul class="children" :class="!(open.index==tagIndex && open.status) ? 'close' : ''" :style="{}">
                        <li v-for="childrenTag in item.name | getChildrenList paths">
                            <a v-link="{ name: 'detail', params: { id: childrenTag.operationId }}">{{ childrenTag.summary }}</a>
                            <span style="display: none;">{ tagIndex === 0 && $index === 0 && disDocData.path && (disDocData=childrenTag) }</span>
                        </li>
                    </ul>
                </li>
            </ul>
        </section>
</template>
<script>
    export default {
        props: ['paths', 'tags', 'disDocData'],
        data() {
            return {
                openList: [],
                open: {
                    index: 0,
                    status: true
                }
            }
        },
        created(){
            
        },
        methods: {
            toggle(index){
                if(this.open.index == index){
                    this.open.status = !this.open.status
                }else{
                    this.open.status = true;
                }
                this.open.index = index
            },
            toPath(data){
                this.disDocData = data
            }
        }
    }
</script>
<style lang="scss">
    .list {
        width: 234px;
        border: 1px solid #e0e1e3;
        padding: 15px;
        background: #fff;
        border-radius: 4px;
        float: left;
        box-sizing: border-box;
        position: absolute;
        left: 0;
        height: 100%;
        overflow: auto;
        ul {
            list-style: none;
            li {
                color: #444853;
                font-size: 16px;
                line-height: 30px;
                overflow: hidden;
                .gray{
                    font-size: 14px;
                    color: #a1a0a9;
                }
            }
        }
        .children {
            padding-left: 10px;
            transition: all .5s;
            li a{
                color: #7a898e;
                font-size: 12px;
            }
            &.close{
                height: 0;
            }
        }
    }
</style>